function [r, k, u, c] = SecantMethod(fx, a, b, eps)
fx = sym(fx);
a = double(sym(a));
b = double(sym(b));
f = inline(fx);
f2 = inline(diff(fx, 2));

r = 0;
k = 0;
u = 0; 
c = true;

if (f2(a) == 0)
    c = false;
    return;
end;

converge = f2(a) < 0;
for step = a : eps * 10 : b
    if (f2(step) < 0) ~= converge
        c = false;
        return
    end;
end

if (f(b) * f2(b) > 0)
    formula = 'xp - f(xp) / ( f(b) - f(xp)) * (b - xp)';
    xpp = a;
else 
    formula = 'xp - f(xp) / ( f(a) - f(xp)) * (a - xp)';
    xpp = b;
end;
xp = xpp;
xp = eval(formula);
xk = eval(formula);
i = 3;
while (xk - xp)^2 / abs(2*xp - xk - xpp) >= eps
    xpp = xp;
    xp = xk;
    xk = eval(formula);
    i = i + 1;
end;
c = true;
r = xk;
k = i;
u = f(xk);

end

